#! /usr/bin/env python
# _*_ coding:UTF-8 _*_
"""
@author:zhh
@Software:PyCharm
@blogs:https://blog.csdn.net/smilehaoh
@time:2020/4/14

"""
from common.connect_db import MyDB

my_db = MyDB()


class Oil:

    @staticmethod
    def get_old_oilorder():
        """
        查询老系统油卡订单
        :return
        """
        sql1 = "select count(*) as old from ims_oil_order where status in (1,2,3,4,5,6) and deleted=0"
        result = my_db.execute_select(select_db='old', db_name="quanfan", sql_text=sql1)
        if len(result) > 0:
            return result
        else:
            raise ValueError("没有查询到相关数据")

    @staticmethod
    def get_old_oilsupplier():
        """
        查询老系统油卡订单供应商
        :return
        """
        sql1 = "select count(*) as old from ims_oil_supplier"
        result = my_db.execute_select(select_db='old', db_name="quanfan", sql_text=sql1)
        if len(result) > 0:
            return result
        else:
            raise ValueError("没有查询到相关数据")

    @staticmethod
    def get_old_oilcard():
        """
        查询老系统油卡总数
        :return
        """
        sql1 = "select count(card) as old from ims_oil_card where deleted=0"
        result = my_db.execute_select(select_db='old', db_name="quanfan", sql_text=sql1)
        if len(result) > 0:
            return result
        else:
            raise ValueError("没有查询到相关数据")

    @staticmethod
    def get_old_zshoilcard():
        """
        查询老系统中石化油卡总数
        :return
        """
        sql1 = "select count(card) as old from ims_oil_card where deleted=0 and card_type=2"
        result = my_db.execute_select(select_db='old', db_name="quanfan", sql_text=sql1)
        if len(result) > 0:
            return result
        else:
            raise ValueError("没有查询到相关数据")

    @staticmethod
    def get_old_zsyoilcard():
        """
        查询老系统中石油油卡总数
        :return
        """
        sql1 = "select count(card) as old from ims_oil_card where deleted=0 and card_type=1"
        result = my_db.execute_select(select_db='old', db_name="quanfan", sql_text=sql1)
        if len(result) > 0:
            return result
        else:
            raise ValueError("没有查询到相关数据")

    @staticmethod
    def get_old_abadoncard():
        """
        查询老系统禁用油卡总数
        :return
        """
        sql1 = "select count(card) as old from ims_oil_card where deleted=0 and status=0"
        result = my_db.execute_select(select_db='old', db_name="quanfan", sql_text=sql1)
        if len(result) > 0:
            return result
        else:
            raise ValueError("没有查询到相关数据")

    @staticmethod
    def get_old_oilrechargeorder():
        """
        查询老系统油卡待充值和充值中订单
        :return
        """
        sql1 = "select count(*) as old from ims_oil_order where status in (3,4,5) and deleted=0"
        result = my_db.execute_select(select_db='old', db_name="quanfan", sql_text=sql1)
        if len(result) > 0:
            return result
        else:
            raise ValueError("没有查询到相关数据")

    @staticmethod
    def get_new_oilorder():
        """
        查询新系统油卡订单
       :return:
        """
        sql = "select count(*) as new from life_third_oil_orders where status in (2,3,4,5,6)"
        result = my_db.execute_select(select_db='new', db_name="third", sql_text=sql)
        if len(result) > 0:
            return result
        else:
            raise ValueError("没有查询到相关数据")

    @staticmethod
    def get_new_oilsupplier():
        """
        查询新系统油卡供应商总数
       :return:
        """
        sql = "select count(*) as new from life_third_oil_suppliers"
        result = my_db.execute_select(select_db='new', db_name="third", sql_text=sql)
        if len(result) > 0:
            return result
        else:
            raise ValueError("没有查询到相关数据")

    @staticmethod
    def get_new_oilcard():
        """
        查询新系统油卡总数
       :return:
        """
        sql = "select count(*) as new from life_third_oil_card "
        result = my_db.execute_select(select_db='new', db_name="third", sql_text=sql)
        if len(result) > 0:
            return result
        else:
            raise ValueError("没有查询到相关数据")

    @staticmethod
    def get_new_abandoncard():
        """
        查询新系统禁用油卡总数
       :return:
        """
        sql = "select count(*) as new from life_third_oil_card where status=-1"
        result = my_db.execute_select(select_db='new', db_name="third", sql_text=sql)
        if len(result) > 0:
            return result
        else:
            raise ValueError("没有查询到相关数据")

    @staticmethod
    def get_new_zshoilcard():
        """
        查询新系统中石化油卡总数
       :return:
        """
        sql = "select count(*) as new from life_third_oil_card where type=2"
        result = my_db.execute_select(select_db='new', db_name="third", sql_text=sql)
        if len(result) > 0:
            return result
        else:
            raise ValueError("没有查询到相关数据")

    @staticmethod
    def get_new_zsyoilcard():
        """
        查询新系统中石油油卡总数
       :return:
        """
        sql = "select count(*) as new from life_third_oil_card where type=1"
        result = my_db.execute_select(select_db='new', db_name="third", sql_text=sql)
        if len(result) > 0:
            return result
        else:
            raise ValueError("没有查询到相关数据")

    @staticmethod
    def get_new_oilrechargeorder():
        """
        查询新系统油卡待充值和充值中订单
        :return:
        """
        sql = "select count(*) as recharge from life_third_oil_orders where status in (4,5)"
        result = my_db.execute_select(select_db='new', db_name='third', sql_text=sql)
        if len(result) > 0:
            return result
        else:
            raise ValueError("没有查询到相关数据")


if __name__ == '__main__':
    oil = Oil()
    a = oil.get_old_oilorder()
    # b=oil.get_new_oilorder()
